package xin.nick.api.fallback;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import xin.nick.api.UserServiceApi;

import java.util.Arrays;
import java.util.List;

/**
 * UserServiceApi 降级
 * @author Nick
 * @since 2023/4/16
 */
@Component
@Slf4j
public class UserServiceApiFallbackFactory implements FallbackFactory<UserServiceApi> {


    @Override
    public UserServiceApi create(Throwable cause) {
        return new UserServiceApi() {
            @Override
            public List<String> getAllList(String username) {
                log.error("调用getAllList出错: ", cause);
                return Arrays.asList("出错了");
            }

            @Override
            public List<String> getUserByUsername(String username) {
                return null;
            }
        };
    }
}
